package com.sinog.front.controller.biz;

import com.sinog.core.model.UserDTO;
import com.sinog.core.util.JsonUtil;
import com.sinog.front.feign.biz.NoticeService;
import com.sinog.front.service.user.UserFacade;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Map;

/**
 * @desc 小铃铛控制器
 * @author lzq
 * @date 2020-07-21 2:46 下午
 */
@RestController
public class NoticeController {

    @Resource
    private UserFacade userService;
    @Resource
    private NoticeService noticeService;

    /**
     * 查询当前用户各项待办事项的条数
     * @return Map<String,Integer>
     */
    @GetMapping("/azbj/notice/remind")
    @ResponseBody
    public Map<String,Integer> getRemind() {
        UserDTO user = userService.getAuthentication();
        String data = JsonUtil.setObjectToJsonStr(null, "departid",user.getDepartid(), "level",user.getLevel());
        return noticeService.count(data);
    }

    /**
     * 获取工作提醒
     * @param type 1:监狱发起核查 2:司法所完成核查 3:监狱发起衔接 4:司法所衔接中 5:司法所发起上报 6:司法所申请解除帮教
     * @return String
     */
    @RequestMapping(value = "/azbj/notice/list", method = RequestMethod.GET)
    public String findMessages(String type) {
        UserDTO user = userService.getAuthentication();
        String data = JsonUtil.setObjectToJsonStr(null, "departid",user.getDepartid(), "level",user.getLevel());
        return noticeService.list(data,type);
    }
}